
<%@ page import="greendbgui.ElectoralRollEntry" %>
<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'electoralRollEntry.label', default: 'ElectoralRollEntry')}" />
        <tooltip:resources/>
		<title>${currentRoll}</title>
	</head>
	<body>
	    
            <g:if test="${flash.message}">
                <div class="message" role="status">${flash.message}</div>
            </g:if>
            
		<div id="search-bar">
		
			<g:form action="search">
			   <g:hiddenField name="id" value="${params.id}"/>
			   
			   Name:
			   <g:textField name="name"/>

			   Address:
			   <g:textField name="address"/>

			   <g:actionSubmit value="Search"/>
			</g:form>
        </div>

        <div id="roll-list">
            <table>
                <thead>
                    <tr>
                        <th>Ward</th>
                    </tr>
                </thead>
                <tbody>
                <g:each in="${rolls}" status="i" var="roll">
                    <tr>
                        <td> 
                           <g:if test="${roll.displayString == currentRoll}">
                               ${roll.displayString}
                           </g:if>
                           <g:else>
                               <g:link controller="electoralRollEntry" action="main" params="[id:roll.id]">
                                   ${roll.displayString}
                               </g:link>
                           </g:else>
                        </td>
                    </tr>
                </g:each>
                </tbody>
             </table>
        </div>
        
        <div id="elector-list">
			<table>
				<thead>
					<tr>
			            <th width="10%"><g:message code="electoralRollEntry.ref.label" default="Reference" /></th>
            
                        <th width="30%"><g:message code="electoralRollEntry.person.label" default="Person" /></th>

                        <th width="50%"><g:message code="electoralRollEntry.address.label" default="Address" /></th>
            							
                        <th width="10%"><g:message code="electoralRollEntry.voteType.label" default="Vote Type" /></th>
					</tr>
				</thead>
				<tbody>
				<g:each in="${electoralRollEntryInstanceList}" status="i" var="electoralRollEntryInstance">
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
					
                        <td>${fieldValue(bean: electoralRollEntryInstance, field: "ref")}</td>
                    
                        <td>
                       <g:link controller="person" action="display" params="[id:electoralRollEntryInstance.person.id]">
                            ${fieldValue(bean: electoralRollEntryInstance, field: "person")}
                       </g:link>
                        </td>
                    
                            <td>
                            <tooltip:tip code="${electoralRollEntryInstance.address.singleLine}">
                                ${fieldValue(bean: electoralRollEntryInstance, field: "address.address1")}
                            </tooltip:tip>
                            </td>
                        
						<td>${fieldValue(bean: electoralRollEntryInstance, field: "voteType")}</td>
					
					</tr>
				</g:each>
				</tbody>
			</table>
			
			<div class="pagination">
				<g:paginate id="${params.id}" 
				            total="${electoralRollEntryInstanceTotal}" 
				            params="[name:params?.name, address:params?.address]" />
			</div>
			
            <g:link controller="electoralRollEntry" action="createReport" params="[id:params.id, name:params?.name, address:params?.address]">
               Create Report
            </g:link>
		
		</div>
	</body>
</html>
